import bpy

# Loop through all objects in the current blend file scene
for obj in bpy.data.objects:
    if "kb" in obj and "bitmap" in obj["kb"]:
        current_texture = obj["kb"]["bitmap"]
        new_texture = current_texture
        
        # Wildcard check: Find "blue" anywhere in the name and replace with "gren"
        if "blue" in new_texture:
            new_texture = new_texture.replace("blue", "gren")
            
        # Only update if a match was found and a change happened
        if current_texture != new_texture:
            obj["kb"]["bitmap"] = new_texture
            print(f"✅ Updated {obj.name}: '{current_texture}' ➔ '{new_texture}'")

# Force Blender UI to redraw so the boxes visually update across the interface
for area in bpy.context.screen.areas:
    if area.type == 'PROPERTIES':
        area.tag_redraw()